package pe.com.cineplanet.bean.cineplanet;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import pe.com.cineplanet.bean.Politic;

public class Constantes {
	
	public static final String ESTADO_USUARIO_ACTIVO = "1";
	public static final String ESTADO_USUARIO_INACTIVO = "2";
	public static final String ESTADO_USUARIO_BLOQUEADO = "3";
	
	public static final String ESTADO_COMENTARIO_ACTIVO = "1";
	public static final String ESTADO_COMENTARIO_INACTIVO = "2";
	
	public static final String TIPO_COMEDIA = "1";
	public static final String TIPO_DRAMA = "2";
	public static final String TIPO_ROMATICA = "3";
	public static final String TIPO_ACCION = "4";
	public static final String TIPO_TERROR = "5";

	
	public static final String PUBLICO_ADULTO = "1";
	public static final String PUBLICO_INFANTIL = "2";
	
	public static final String EMISION_2D = "1";
	public static final String EMISION_3D = "2";
	
	public static final String CARRITO_NUEVO = "1";
	public static final String CARRITO_ENPROCESO = "2";
	
	
	public static String completar(String text, int len){
		StringBuffer t = new StringBuffer();
		for(int i=0; i<len; i++){
			if(i<text.length())
				t.append(text.charAt(i));
			else
				t.append(" ");
		}
		return t.toString();
	}

	public static String formatearHorario(String horario){
		StringBuffer hFinal = new StringBuffer();
		String[] horarios =horario.split(",");
		if(horarios.length==0) return "";
		for(String h : horarios){
			if(hFinal.length()>0)
				hFinal.append(" / ");
			String f = h.trim().substring(0,2);
			String l = h.trim().substring(2,4);
			hFinal.append(f);
			hFinal.append(":");
			hFinal.append(l);
		}
		return hFinal.toString();
	}
	
	public static List<Politic> defaultMenu(){
		List<Politic> list = new ArrayList<Politic>();
		list.add(new Politic(1, "Vision", 1, 0, 7));
		list.add(new Politic(2, "Historia", 1, 0, 8));
		list.add(new Politic(3, "Cartelera", 1, 0, 2));
		list.add(new Politic(4, "Carrito Compras", 1, 0, 3));
		list.add(new Politic(5, "Usuario", 1, 0, 4));
		list.add(new Politic(6, "Perfil", 1, 0, 5));
		return list;
	}

	public static String[][] formatMenu(List<Politic> menuList){
		String[][] values = new String[menuList.size()][4];
		Iterator<Politic> i = menuList.iterator();
		int row = 0;
		while(i.hasNext()){
			Politic p = i.next();
			values[row][0] = String.valueOf(p.getId());
			values[row][1] = p.getDescription();
			values[row][2] = String.valueOf(p.getParent());
			values[row++][3] = (p.getModule()==0)?null:String.valueOf(p.getModule());
			
		}
		return values;
	}
	
}
